#include <bits/stdc++.h>
using namespace std;

string s = "";  // target string
int pos = 0;    // current postion

int dfs() {
    int tmp = 0; // temporary variable to store the character of x
    int ret = 0; // return result; 
    int len = s.size();
    while (pos < len) {
        if (s[pos] == '(') {
            // (   continue recursion, equivalent to stacking
            pos++;
            tmp += dfs();
        } else if (s[pos] == ')') {
            // )  return recursion, equivalent to popping
            pos++;
            break;
        } else if (s[pos] == '|') {
            // check or
            pos++;
            ret = max(ret, tmp);
            tmp = 0;
        } else {
            // calculate and count the character of x
            pos++;
            tmp++;
        }
    }
    return max(ans, tmp);
}


int main() {
    cin >> s;
    cout << dfs() << endl;
    return 0;
}